package cn.qingyun.gis.modules.baogan.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.baogan.service.MicroStreetDataService;
import cn.qingyun.gis.modules.baogan.service.impl.MicroStreetAuditLogService;
import cn.qingyun.gis.modules.baogan.vo.request.*;
import cn.qingyun.gis.modules.baogan.vo.response.AoiBaseInfoVo;
import cn.qingyun.gis.modules.baogan.vo.response.ChannelItemVo;
import cn.qingyun.gis.modules.baogan.vo.response.StreetBaseResponse;
import cn.qingyun.gis.modules.baogan.vo.response.TeamItemVo;
import cn.qingyun.gis.modules.init.system.annotation.AutoLog;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.locationtech.jts.io.ParseException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * @author wz
 * @version JDK 8
 * @className TeamController
 * @date 2024/11/6
 * @description 沿街面或绘制面
 */
@RestController
@Slf4j
@RequestMapping("/micro/street/data")
public class MicroStreetDataController {

    @Resource
    private MicroStreetDataService microStreetDataService;
    @Resource
    private MicroStreetAuditLogService microStreetAuditLogService;

    @AutoLog(value = "沿街面或绘制面-看管划分-基本信息查询")
    @PostMapping("/watchDivision/getBaseInfo")
    @ApiOperation(value = "沿街面或绘制面-看管划分-基本信息查询")
    public Result<?> getWatchDivisionBaseInfo(@Validated @RequestBody IdRequest request) {
        StreetBaseResponse response = microStreetDataService.getWatchDivisionBaseInfo(request);
        return Result.okData(response);
    }

    @AutoLog(value = "沿街面或绘制面-看管划分-查询团队人员")
    @ApiOperation("沿街面或绘制面-看管划分-查询团队人员")
    @PostMapping("/listTeam")
    public Result listTeam(@RequestBody @Validated GridCodeAndKeyListRequest request) {
        List<TeamItemVo> result = microStreetDataService.listTeam(request);
        return Result.okData(result);
    }

    @AutoLog(value = "沿街面或绘制面-看管划分-查询渠道列表")
    @ApiOperation("沿街面或绘制面-看管划分-查询渠道列表")
    @PostMapping("/listChannel")
    public Result listChannel(@RequestBody @Validated GridCodeAndKeyListRequest request) {
        Set<ChannelItemVo> result = microStreetDataService.listChannel(request);
        return Result.okData(result);
    }

    @AutoLog(value = "查询绘制面中的建筑数、企业数")
    @ApiOperation("查询绘制面中的建筑数、企业数")
    @PostMapping("/getAoiBaseInfo")
    public Result getAoiBaseInfo(@RequestBody @Validated AoiBaseInfoGetRequest request) {
        AoiBaseInfoVo result = microStreetDataService.getAoiBaseInfo(request);
        return Result.okData(result);
    }


    /**
     * 审核接口
     * @param request
     * @return
     */
    @PostMapping("/review")
    public Result<?> review(@RequestBody @Validated ReviewRequest request){
        return Result.okData(microStreetAuditLogService.review(request));
    }


    @ApiOperation("查询待审核的面列表")
    @PostMapping("/query/audit/list")
    public Result<?> selectPendingAuditData(@RequestBody @Validated PendingAuditRequest request) {
        return Result.okData(microStreetDataService.selectAuditData(request));
    }
    @ApiOperation("开启周边查询")
    @PostMapping("/perimeter/query")
    public Result<?> selectPerimeterData(@RequestBody @Validated PerimeterRequest request) {
        return Result.okData(microStreetDataService.selectPerimeterData(request));
    }


    /**
     * 审核页面查询面详情
     * @param id  面id
     * @param microGridCode 微网格code
     * @return
     */
    @GetMapping("/query/reviewing/detail")
    public Result<?> getReviewingDetail(@RequestParam(value = "id") String id,@RequestParam(value = "microGridCode") String microGridCode) {
        return Result.okData(microStreetDataService.getReviewingDetail(microGridCode,id));
    }
}
